/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ec.socialfun.servicios;

import com.ec.socialfun.entidades.Rol;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author hp
 */
@Stateless
public class RolFacade extends AbstractFacade<Rol> {
    @PersistenceContext(unitName = "SocialFunPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public RolFacade() {
        super(Rol.class);
    }
    
    public Rol recuperaPorNombre(String nombre){
        Query q = em.createNamedQuery("Rol.findByRoNombre");
        q.setParameter("roNombre", nombre);
        return (Rol)(q.getResultList().isEmpty()? null:q.getResultList().iterator().next());
    }
    
}
